Skip to content

gh-101561: Add typing.override decorator#101564

Merged
JelleZijlstra merged 10 commits intopython:mainfrom
stroxler:gh-101561-typing-override
Feb 27, 2023
Merged

gh-101561: Add typing.override decorator#101564
JelleZijlstra merged 10 commits intopython:mainfrom
stroxler:gh-101561-typing-override

Conversation

@stroxler
Copy link
Contributor

@stroxler stroxler commented Feb 4, 2023

The code is pulled almost unchanged from typing_extensions:

Question that came up was where to put the type variable and what to name it:

  • In typing_extensions the type variables use underscore prefixes to indicate that they are not public, but typing doesn't appear to use that convention so I named the type variable F.
  • I couldn't put the type variable next to all of the other ones (used in generic container definitions) because it relies on Callable which is defined below. If this is a problem I could correct it using a forward reference, or we could try to rearrange the module to put special forms above type variables.

Testing the code:

First set up the repo, following instructions
at https://devguide.python.org/ by running:

./configure --with-pydebug && make -j

Then run the typing tests:

./python -m test test_typing -v

I ran the full test suite with

./python -m test -j3

and it came back clean except for a test_grp failure which I seem to get on trunk as well - likely something in my build is misconfigured but I'm pretty sure it is unrelated to the changes here.

Make sure the docs build:

cd Doc
make venv
make html

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3.12 only security fixes stdlib Standard Library Python modules in the Lib/ directory topic-typing type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants